# import asyncio

# from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver
# from langgraph.graph import StateGraph

# async def main():
#     builder = StateGraph(int)
#     builder.add_node("add_one", lambda x: x + 1)
#     builder.set_entry_point("add_one")
#     builder.set_finish_point("add_one")
#     async with AsyncSqliteSaver.from_conn_string("checkpoints.db") as memory:
#         graph = builder.compile(checkpointer=memory)
#         coro = graph.ainvoke(4, {"configurable": {"thread_id": "thread-1"}})
#         print(await asyncio.gather(coro))

# asyncio.run(main())
# Output: [2]

import asyncio
import aiosqlite
from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver

async def main():
    async with aiosqlite.connect("checkpoints.db") as conn:
        saver = AsyncSqliteSaver(conn)
        config = {"configurable": {"thread_id": "1", "checkpoint_ns": ""}}
        checkpoint = {"ts": "2023-05-03T10:00:00Z", "data": {"key": "value"}, "id": "0c62ca34-ac19-445d-bbb0-5b4984975b2a"}
        saved_config = await saver.aput(config, checkpoint, {}, {})
        print(saved_config)
asyncio.run(main())
# {'configurable': {'thread_id': '1', 'checkpoint_ns': '', 'checkpoint_id': '0c62ca34-ac19-445d-bbb0-5b4984975b2a'}}